home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr22
/
mcalc199.zip
/
MCALC.DOC
< prev
next >
Wrap
Text File
|
1995-01-22
|
66KB
|
1,955 lines
Mcalc : The Master Calculator.
Registering Mcalc.
------------------
Mcalc is not "free", neither it is "public domain". It is a copyrighted
and commercial program distributed through the shareware channel. This
allows you to try the program first to see if it suits your needs. If
you decide to continue using it after 3 weeks, then you are expected to
pay the author a registration fee, which costs only 2000 Bef or $49 for
individual use, or less per machine if you get a site license. Some
users may even qualify for a free registration.
All the features present in the registered version are also present in
the evaluation copy. Only the extra add-in utilities have been removed
from this copy as they could need too much disk spaces to be distribu-
ted in a convenient way via the most used shareware channels: BBS and
phone links. I think that by letting you try all of the features, you
will decide to register if you want to continue using this program.
Please, help prove me right be sending your registration.
Your registration will motivate me to spend the time and resources
necessary to add some of the features that you ask for. The delay
screen at the end of this evaluation copy is not present in the
registered version.
Please, refer to the ORDER.DOC for instruction on how to register
Mcalc, and prices.
I will try to extend my support to unregistered users during their
evaluation period, however, I reserve the right to limit my support for
unregistered users if their requests become taxing for me. You may
correspond by postal mail: please, send a self adressed stamped
enveloped in order for me to reply. If your adress is outside Belgium,
add a $1 money for the answer costs.
Free registration for qualified students: if your school lab has a site
license for the Master Calculator for use on 10 or more computers, then
up to five students from your school can receive a free registered copy
of the program. All you have to do is send me your request, along with
thename of your school. Please, check first to make sure you qualify
for this offer.
A site is considered to be any corporation, institution, government
agency, computer lab, or non-personal organization, with more than one
computer capable of running Mcalc software, and with a locally
accessible tech support person or team. A site may use the evaluation
version for evaluation only. If the site decides to continue using
Mcalc after 21 days, a site license must be purchased. See the
ORDER.DOC for low rates that are available. A site license is for use
within the site and is not transferable.
1
Mcalc : The Master Calculator.
This license allows the internal use and copying of the sofware by as
many computers as contracted for. The unregistered version may be
freely distributed.
The Master Calculator software is distributed on an "as is" basis
without any warranty of any kind, expressed or implied. The author will
not be liable for any special, incidental, consequential, direct or
indirect damages due to any malfunctions.
My adress: Didier Gosseau.
Rue Georges Lorand nΦ 19.
B 1050 Brussels.
Belgium.
Distribution: You are encouraged to distribute the shareware version
of Mcalc. The following files must be present and unmodified:
Mcalc.exe Master calculator task.
Mcalc.hlp & Mcalc.hl2 On-line text and index files.
mc_unit.dat Physical units database.
Mcalc.key User key definition file.
Helvb.fon Helveticca characters fonts.
demo.bat demo.mac Demonstration macro and auxillary files.
demo03a.mcp demo04.mcp
demo05.txt
mcalc.doc This file.
order.doc The ordering form.
The compressed file name must be MCALC19.??? with ??? being ARJ, ZIP or
whatever compression suffix being used.
2
Mcalc : The Master Calculator.
Contents.
---------
1. Introduction.
2. Mcalc features.
3. Installation.
4. Getting started.
5. Getting help with Mcalc.
6. A few first steps using Mcalc.
7. The Mcalc user interface in brief.
8. Functions and commands.
9. Procedures.
10. Using the plotter and the solver.
11. Using the statistical functions and commands.
12. Numerical analysis.
13. Physical units conversion.
14. Using the keyboard macros.
15. Advanced and particular topics.
16. The Mcalc files.
1. Introduction.
----------------
Mcalc is a scientific calculator for MSDOS based computers that offers
a lot of features most of the time only available in high class
scientific packages. Mcalc offers a lot of build in functions,
operators, numerical notations and modes. Graphics, keyboard macros,
user task extensions and many more are available. Expressions such as
the following can be computed:
63 - 5 + 4.821
(5.9-abs(2.8/5-3))^2+sin(3-(pi+3/4)
15 * sin(pi/4)+abs(10-5+log(20)^2+9) - #b101110111
3
Mcalc : The Master Calculator.
2. Mcalc features.
------------------
- double precision 64 bits floating number calculation.
- logical arithmetic syntax using a BASIC like recursive descent
expression parser.
- rich set of scientific functions including gaussian curve, bessel
functions, statistical functions...
- interactive functions, procedures and experimental data sets
plotter.
- rich set of commands including plotter, equation solver,
integration, interpolation, multi-model regressions,
correlation...
- multiple programmer radix notation: decimal, hexadecimal, octal
and binary.
- programming possibilities via Procedure-Basic.
- on-line hypertext help system.
- physical units converter and intelligent units database.
- customizable user keys.
- keyboard macros.
- extension possibilities via user "tasks".
- session login file support
- support CGA, EGA, VGA and coprocessor hardware on any AT, 386, 486
and PENTIUM platform.
- needs MSDOS 3.3 or later.
3. Installation.
----------------
Make a \mcalc subdirectory into your harddisk and copy all the files to
it. All files beginning with "demo**.***" constitutes a demonstration
tutorial of Mcalc possibilities. They are not necessary for commun use
and can be deleted if you don't plan to run the demonstration.
Mcalc must be run from its current directory.
4. Getting started.
-------------------
There are three ways to run Mcalc:
- from the command line: mcalc 5+4*8/2
4
Mcalc : The Master Calculator.
- in evaluation mode: mcalc [enter]
when you are in this mode, you get the mcalc> prompt that invites
you to enter a mcalc command or an expression to be evaluated. In
this mode, strike [F1] at any time for help, or [Alt-F10] to quit
the program. See the examples later in this documentation to get
more ideas about using Mcalc.
- in procedure mode. You can evaluate a procedure from within Mcalc.
The best way to evaluate Mcalc is first to run the demonstration
tutorial. To do that, make sure that you are in the Mcalc subdirectory
and that the following files are available:
- mcalc.exe, mcalc.hlp and mcalc.hl2
- helvb.fon, mcalc.key and mc_unit.dat
- demo.bat, demo03a.mcp, demo04.mcp and demo05.txt
From the DOS, give the following command:
DEMO.BAT
The demonstration tutorial is started. Don't strike any key during the
demonstration, excepted when the <<<Demo is pausing>>> label is
displayed. The compleet demonstration takes approximately 20 minutes.
After the demo, you will have a good idea about Mcalc possibilities.
If something goes wrong or you want to abort the demo, strike one or
more time the [Ctrl End] key. Then, at the mcalc> prompt, type the
'quit' command, followed by [Enter].
After the demo, continue the evaluation Mcalc by yourself. You should
look at the on-line help system if you need detailled information about
a particular topics. This documentation is just intended to help you
starting with Mcalc. Each time you should learn more detailled info, we
will direct you to a particular help topic.
5. Getting help with Mcalc.
---------------------------
Inside Mcalc, you can obtain help at any time, by striking [F1] in
response to the Mcalc> prompt. You can also get help, by entering the
'help' command followed by return. You can finally obtain help about a
particular subject by entering the 'help' command, followed by the
subject between double quotes.
For example, to obtain help about the on-line help system, strike:
help "???"
5
Mcalc : The Master Calculator.
6. A few first steps using Mcalc.
---------------------------------
The first time you use Mcalc, you will get the following screen:
Mcalc, the Master Calculator. Version : 1.99
Copyright (C) 1994 by Didier Gosseau.
Give 'help' or strike F1 for help, 'listk' or Ctrl F1 for function
keys.
'mcalc.ini' not found! Default values will be used...
Use the 'setup' command to customize them.
Mcalc >
This is normal. Mcalc uses default values that are customized. It store
them into the 'mcalc.ini' file. At the first usage, that file does not
already exists. Mcalc created it and give you a warning. We will ignore
that message for now, and performs a few using the default
parameters.When you get the "mcalc >" prompt, this means that Mcalc is
ready and wait for a command or an expression to compute.
6.1.Evaluating a simple expression.
-----------------------------------
Mcalc is now ready to evaluate a simple expression. Let suppose you
want to compute the following:
12.4 * 5 / 4
You just strike this expression, as you would normally write it on a
paper, and Mcalc supplied immediately the answer:
mcalc > 12.4*5/4
Answer = 15.5
mcalc >
As you see, each time you strike an expression, it is directly
evaluated using the standard arithmetic notation. Later in this manual,
we will explain in details the rules used to write correctly an
expression.
6
Mcalc : The Master Calculator.
6.2. Evaluating a complex expression.
-------------------------------------
Mcalc is also directly suitable to evaluate a more complicated
expression, involving number and constants.
For example, let us try to find the value of a second order polynomial:
ax^2 + bx + c
where a=1, b=-2 and c=-3. Let suppose x=-5. You could for example
directly strike:
mcalc > 1*(-5)^2-2*(-5)-3
Answer = 32
but it is also possible to use variables to store constant values....
mcalc > a=1
mcalc > b=-2
mcalc > c=-3
mcalc > x=-5
mcalc > +a*x^2+b*x+c
Answer = 32
6.3. Writing a simple procedure to plot this polynomial.
--------------------------------------------------------
If you have to evaluate this polynomial for multiple values of x, it is
preferable to write this equation as a simple procedure. For example,
you can write directly the equation:
y = ax^2 + bx + c
as a procedure that can be evaluated or plotted later. To do that, you
give the edit command, that enter the edit mode. Then, you strike e to
select the (E)dit option of the displayed menu. You are now in the
Internal editor. Despite its very limited features, it is enough for
today to enter this one line equation. You strike now directly the
equation, just like you would have written it on a paper! Strike:
y=a*x^2+b*x+c followed by a Return. The first and unique line of this
small procedure is written. You strike now ESCape to quit the internal
editor. If you want, you can save the procedure as a file for later
usage. To do that, strike s to select the (S)ave function. Mcalc prompt
7
Mcalc : The Master Calculator.
you for a file name. Enter for example: ex1 followed by Return. Your
screen looks now like the following:
y=a*x^2+b*x+c
Command mode : (L)oad, (S)ave, (E)dit, (R)un, (N)ew, (D)ir ,(Q)uit
You have now written a procedure that compute an expression that is
function of the variables a,b,c and x and that returns a value into the
variable y. In our case, a,b and c are constants and their values are
already stored. We don't need to enter them again. As long as you stay
within Mcalc, the values assigned to variables are not lost. We have
thus a procedure that is a function of variable x and that send back an
answer in variable y.
Strike now q to (Q)uit the editor mode. You get back the mcalc> prompt.
You can now plot the function using the plot command. To plot a
procedure, you just need to specify the independent or input variable
name (in our case 'x'), the dependant or output variable (here 'y'),
the first and last values of the input variable, and the number of
points to plot. In this example, we plot 100 points for x in the range
[-5,10].
mcalc > plot x,y,-5,10,100
You are now in interactive mode. This mode give you some possibilities
that will be explained in great details in chapter 5. For now, just
look at the graphic and note that the function has two roots at
approximately -1.5 and +3.5. It is now interesting to use the solver to
find the exact values of these roots.
6.4. Using the solver.
----------------------
To use the solver, you write a procedure exactly on the same manner as
you do to plot a function. In this example, the procedure EX1 is
already loaded and ready for use. You find a root using the solve
command. You must also specify the independent or input variable name,
the output variable and an initial root value to start the solver. In
this example, we start searching a root from -1.5.
8
Mcalc : The Master Calculator.
mcalc > solve x,y,-1.5
Solving the procedure .....
Solver root/extremum found:
Root = -1.00000009449577 [ -1.5 ]
Eval = 3.7798309193704e-007
Another case ? = <Y>
Initial approximation [ -1e+050,1e+050 ] = 3.5
Solving the procedure .....
Solver root/extremum found:
Root = 3.00000009763274 [ 3.5 ]
Eval = 3.90530948024548e-007
Another case ? = <N>
mcalc >
As you can see, Mcalc has found a first root at -1 and a second one at
+3. This was of course the expected results for such quadratic
polynomial....
7. The Mcalc user interface in brief.
-------------------------------------
7.1. Evaluation and procedure modes.
------------------------------------
Mcalc uses two working modes: evaluation and procedure.
When you start Mcalc, you get the 'mcalc >' prompt. This means that you
are in evaluation mode. Each time you enter one line and press Return,
Mcalc evaluate the line you typed and look to compute the expression,
or to recognize a command and execute it. In this mode, Mcalc can only
recognize three basic situations:
An expression is available. In this case, Mcalc evaluate it and returns
the value with the 'answer' prompt.
mcalc > *12*sin(45)+exp(-1)*fact(5)
Answer = 52.630814314811640
Mcalc can evaluate many expressions in one step. Multiple expressions
must be separated by "space" characters.
9
Mcalc : The Master Calculator.
mcalc > 12/3 4*5 (4+2)/0.1
Answer = 4
Answer = 20
Answer = 60
The second case is a variable assignment. In this case, you assign the
value of an expression to a variable, like in the following example:
mcalc > a=sin(45)/3
The expression (in this example: sin(45)/3 ) is evaluated and the
resulting value is stored into the specified variable ('a' in this
case!).
The last case, a command is given and will be processed....
mcalc > cls
In this example, the 'cls' keyword is recognized and will be executed.
It clears the screen's contents.
7.2. The notation used.
-----------------------
Mcalc use a notation for the functions, commands and expressions that
is very similar to BASIC. This is the reason that we have called the
procedure language the Procedure Basic. You should only keep in mind
that normally any expression is supposed to be in decimal. Other radix
numbers can be entered using a particular prefix. The '#' sign
introduces another radix than decimal. Mcalc recognizes the following
prefix:
#x #h #o #b #a and #v.
For more info: help "notation"
7.3. Specifying default parameters with 'setup'.
------------------------------------------------
In practice, Mcalc does not ask you every time if arc expressions are
entered in degree or radian, if a mouse must be used in graphical mode
, and so on. Mcalc based its behaviour on default parameters that you
can modify using the 'setup' command. When the command is given, Mcalc
starts a dialogue where is displays each current settings. You can
modify a setting by entering another value.
10
Mcalc : The Master Calculator.
If you strike just a Return, you means that you agree with the proposed
value and don't want to modify it.
If you strike just a /, you means that you agree with the proposed
value, don't want to modify it, nor any further question. Giving a
slash ('/') in a Mcalc dialogue means that you want to stop that
dialogue!
When you quit Mcalc, your current settings are saved into a file
'mcalc.ini'. The next time you start Mcalc, the settings are directly
loaded from that file and available. The first time you use Mcalc,
default settings values are used because the 'mcalc.ini' file does not
exist!
For more info: help "setup"
7.4. User defined keys.
-----------------------
The functions keys F1 to F10 and their associated keys, Shift, Control
and Alternate are called user defined keys.
When you install Mcalc, some strings are associated to some of these
keys. If you give the liskk command, Mcalc replies with the list of all
user defined keys that have some string attached to them.
For more info: help "listk"
7.5. Last result and last commands.
-----------------------------------
When in evaluation mode, Mcalc always remember the last answer and
store it internally. The 'last' keyword is used as an expression
returning the last calculation answer. By that way, it is very easy to
split a long calculus into smaller one, without having to retype the
answer. For example, suppose you have to compute the following
expressions:
12/(45-32)
12/(45-32) + 1/8
As you can see, the second expression will be the same as the first
one, but having 1/8 added. You do this easily with Mcalc using the
following sequence:
11
Mcalc : The Master Calculator.
mcalc > 12/(45-32)
Answer = 0.923076923076923
mcalc > last+1/8
Answer = 1.048076923076923
mcalc >
For more info: help "last"
Another useful features of Mcalc evaluation mode is the ability to
retrieve previous expression to modify them. Mcalc remembers the 20
last expressions or commands you have used in evaluation mode. By
striking the Up arrow, you display the previous expression from the
buffer. By striking the Down arrow, you retrieve the next expression.
If you have executed correctly this tutorial worked example, by
following carefully the steps described in this documentation, if now
you strike once the Up key, you get the following:
mcalc > last+1/8
If you strike immediately return, the same expression is evaluate
again. Do it now.
mcalc > last+1/8
Answer = 1.173076923076923
mcalc >
As you can see, you don't obtain the same result, because with such
kind of expression, each type you evaluate it, the next last result is
stored into the 'last' variable!
Suppose now that you have to evaluate the following expression:
12/(45-32) + 1/6
The quickest way to do it is to retrieve the previous expression that
look the most like this one. Strike the Up key until you see the
following on your screen:
mcalc > 12/(45-32)
Now, strike 10 times the Right key until the cursor is just after the
closing ). An other manner is to strike the End key, that moves the
cursor at the end of the line.
Now, fill the remainder of the expression: +1/6 and strike a return.
You obtain:
12
Mcalc : The Master Calculator.
mcalc > 12/(45-32)+1/6
Answer = 1.089743589743590
Please, remember that in evaluation mode, the Up and Down keys display
the previous or next expressions from the list of the last 20
previously evaluated expressions or commands. The End and Home keys
move the cursor at the end or the beginning of the current line. The
Enter or Return keys start the evaluation of the expression, or
command. If the key is not at the beginning or the end of the line,
everything at the right of the cursor is ignored.
7.6. Changing the output format.
--------------------------------
Mcalc offers you the possibilities to modify the output number
presentation. To do that, you use the format command. By default, Mcalc
displays numbers in floating notation using 15 digits after the dot.
You may modify this in accordance with your own needs using the
following syntax:
format "format string"
The format is defined using the language C ANSI format specifiers.
For more info: help "format"
7.7. Evaluating an expression and respecting priorities.
--------------------------------------------------------
The kernel of Mcalc is a piece of software called the parser. The
parser, or expression parser, transforms numeric expressions into a
form that the computer can understand and evaluate. In Mcalc, we use a
recursive descent parser. This complicate name means that any
expression is decomposed into simplest one, that are also decomposed
and this process occurs until the expression is reduced to a single
value. Despite the fact that this looks very complicated to explain in
details, it is exactly the same as what you do implicitly when you try
to solve an expression like:
9/3 - (100 + 56)
When you compute such expression, first you recognize that this
expression is composed of two terms: 9/3 and (100+56).You break the
expression into a sum (or difference) of terms.
13
Mcalc : The Master Calculator.
Next, for each term, you break it into a product of factor. (The
product can be a multiplication of a division.)
In this case, the first term 9/3 is composed of the two factors 9 and
3.
Next, each factor can be a variable, a number or an expression. If it
is an expression, the same process must be repeated reccursively:
breaking into terms and factors and subexpression. In this example, the
factors 9 and 3 being the simplest numbers, the term 9/3 = 3 can be
evaluate.
The second term (100 + 56) must now be evaluate. We break it into terms
100 and 56. Each term is broken into factors: here very obvious : 100
and 56. The second term is evaluate and is 156.
Now the expression is reduced to two terms : 3 - 156. They are broken
into terms: 3 and 156. These terms are obvious and cannot be split into
factor. They are thus directly evaluated and we obtain finally : -153.
As you can see from this process, Mcalc will naturally follows some
precedence of operators when parsing an expression. From the highest to
the lowest priorities, it recognizes:
functions
( )
^ means 'power of' 2^3 = 2 * 2 * 2
* / multiplication & division
+ - sum and difference
This means that the following expressions are equivalent:
9/3 + 100 + 56
(9/3) + (100+56)
Because / is executed before +, an expression like (9/3)+ is the same
as 9/3+ .
Also, (100 + 56) will be computed before +100 + 56, but the result is
the same!
But, you must use parenthesis if you assign more priorities to the sum
than for the product, because in such case you don't respect Mcalc
parser rules. For example:
14
Mcalc : The Master Calculator.
(9+3) / (4+5)
is not the same as: 9+3 / 4+5
Don't forget that Mcalc ignores the tabulations and spaces in an
expression.
7.8. Using variables.
---------------------
Mcalc provides 26 direct access variables named 'a' to 'z'. You can use
them to store temporary values or constants very often used, or during
a procedure. Mcalc also supplies up to 8000 indirect access variables.
The number of available variables depends of your memory and the setup.
For more info: help "variables"
For more info: help "setup"
For more info: help "list"
8. Functions and commands.
--------------------------
The Mcalc's parser recognizes some keywords. These keywords are linked
to a particular meaning. Each keyword can be a function, a command or a
separator.
A function evaluate an expression and returns an unique value. That
value can be displayed or used inside a more complex expression. The
function takes expects eventually a list of other expression enclosed
into (). Some expression expects no argument and return a value, like
'pi'. Other expects one or more arguments as 'sin(arc)'.
A command is a special keyword that expects eventually some extra
arguments using a particular syntax. It initiates an action. The action
can display a result, but does not returns a value.
In other words, a function can be enclosed into an expression, while a
command may expect one or more expressions as arguments, but cannot be
enclosed itself into another expression.
For more info: help "keywords"
For more info: help "functions"
For more info: help "commands"
15
Mcalc : The Master Calculator.
9. Procedures.
--------------
9.1. Purpose and limitations of "Procedure-Basic".
--------------------------------------------------
The Procedure-Basic language is the programming language used by Mcalc.
Some commands are used in evaluation mode, like for example format,
edit, list ... but most of the commands are used in procedure running
mode. Up to now, we have always used Mcalc as a simple calculator. This
means that expressions and commands were directly processed from the
command line. This is the evaluation mode.
It is also possible to write a series of instructions into a file
called a program or a procedure. Then you run the compleat procedure
after. This delayed mode is called the procedure mode. The language
used to write such procedures is called Procedure-Basic because it is a
BASIC like language.
Procedure-Basic is intended to write procedures, not programs. Mcalc
being a calculator and not a BASIC interpreter, we consider a procedure
as a small program only intended to describe easily some equations or
to perform simple tasks. Due to this specific and limited purpose,
Procedure-Basic is a small subset of BASIC, but includes powerful
commands like solve, plot ... Also a procedure is subject to the
following limitations:
- no string character variables and operators.
- only one instruction or expression by line.
- maximum 50 lines / procedure.
- incorporated editor works only with the 20 first lines of a
procedure.
You should not consider Procedure-Basic as a traditional programming
language to write sophisticated programs. It is only intended to write
single tasks or medium complexity expressions.
9.2. The Procedure-Basic instructions set.
------------------------------------------
We only introduce here the various keywords of Procedure-Basic. Please,
refer to the on-line help for detailed explanations about each keyword.
The language recognizes the following:
The input and print commands are used to perform input/output with the
user. 'input' is used to temporary stop the program, let the user enter
a value which is assigned to a variable. The 'print' command is used to
display string message and expression's values.
16
Mcalc : The Master Calculator.
Specific input/output operations from/to text files are possible using
read, read_, write, close, finput, finput_ and print. These permits
reading values from a file, processing them with Mcalc and writing
results back to another file.
The if...then and goto commands are used to control the execution flow
conditionally and unconditionally.
The gosub and return keywords are used to redirect the execution flow
to/from subroutine. Up to 20 levels of subroutines may be cascaded. A
subroutine is useful to perform continuously the same task, without
having to rewrite it at many place in the procedure. You can also use
run to chain a procedure to another one.
The for...to...step and next keywords are used to perform loop
operation.
Finally graph,pixel, dot and line are used for procedure controlled
graphics.
The end keyword is used to finish a procedure execution.
For more info: help "procedure_basic"
9.3. Writing a simple procedure.
--------------------------------
Let suppose you have very often to convert distance from km to miles.
It could be useful to write a simple procedure that ask you to enter a
distance in km and that convert it into mile. The conversion result is
displayed and the execution finish.
Such a procedure is trivial and could be:
input "Enter km to convert : ",k
print "Equivalent in mile : "; k / 1.609344
end
To edit and save such procedure, from the Mcalc prompt, give the edit
command. Strike now a e to (E)dit the procedure. Enter the three lines
and finish each with a enter. Strike the <ESC> key to return to menu.
Select now option (S)ave and save this procedure under the name 'mile'.
The screen looks now as this one :
17
Mcalc : The Master Calculator.
input "Enter km to convert : ",k
print "Equivalent in miles : ";k / 1.609344
end
Command mode : (L)oad, (S)ave, (E)dit, (R)un, (N)ew, (D)ir, (Q)uit
The procedure is ready to run. Run it by striking the (R)un option. You
obtain the following screen if you answer for example 10 at the
question.
Enter km to convert : 10
Equivalent in miles : 6.213711922373339
Mcalc >
To execute a second case, strike the F2 key or type edit and strike r
again. Answer another value.
If you have to convert many values, it is preferable that the program
is modified like this one:
10 input "Enter km to convert (negative value to quit) : ",k
if k < 0 then end
print "Equivalent in mile : "; k / 1.609344
goto 10
To modify the program, select again F2 or edit, then the (E)dit option.
Now you have to retype completely the first line. (The small
incorporate editor does not support character insertion.) Finish the
line with a enter. This will automatically insert an empty line for the
second line of our procedure. Now type the line 'if k<0 then end' but
don't strike any Enter at the end of this line. Move now the cursor to
the beginning of the fourth line and overwrite the 'end' with 'goto
10'.
Strike an <ESC> to quit the edition mode. Select (R)un. Because you
have modified the procedure, Mcalc ask you if you want to save it.
Answer 'Y' for Yes and return. The previous file is overwritten by the
new one, and the execution is started....
Enter km to convert (negative value to quit) : 1
Equivalent in miles : 0.621371192237334
Enter km to convert (negative value to quit) : 10
Equivalent in miles : 6.2137119223733900
Enter km to convert (negative value to quit) : 100
Equivalent in miles : 62.1371192237339000
Enter km to convert (negative value to quit) : 2
Equivalent in miles : 1.242742384474668
Enter km to convert (negative value to quit) : -1
18
Mcalc : The Master Calculator.
Mcalc >
For more info: help "edit"
For more info: help "internal_editor"
9.4. Running a procedure.
-------------------------
To execute a procedure, you have the following possibilities:
1. Go in editor mode with edit.
Load the procedure to the editor memory with (L)oad.
or Write the procedure with (E)dit.
Select the (R)un option.
2. If the procedure is already in the editor memory....
Strike F2 followed by R.
3. You can also directly load a procedure from a file and run it with
the run command.
For example: quit Mcalc, restart it and give directly the command:
run 'mile'
Mcalc > run "mile"
Enter km to convert (negative value to quit) : 12
Equivalent in miles : 7.4564543068980070
Enter km to convert (negative value to quit) : -1
Mcalc >
4. If a procedure begins with a label (the address of a goto
statement for example) and is already loaded into memory, you can
run it with the run command followed by that label.
For example, our 'mile' procedure begins with the label '10'. You
can run it again by giving:
Mcalc > run 10
Enter km to convert (negative value to quit) : 2
Equivalent in miles : 1.242742384474668
Enter km to convert (negative value to quit) : -1
Mcalc >
For more info: help "run"
19
Mcalc : The Master Calculator.
9.5. Multiple entries procedure and function keys.
--------------------------------------------------
With Mcalc, you can write multiple entries procedure and call each
subprocedure using its label or a function key. For example, write the
following procedure and save it under the name 'convert'.
1 input "km-->mile : ",k
print k;" km = "; k/1.609344 ; "mile"
end
2 input "mile-->km : ",k
print k;" mile = "; k*1.609344 ; "km"
end
Now, be sure that this procedure is loaded into the editor memory. (To
be sure, give the edit command: the procedure must be displayed). If it
is not the case load it. Quit the editor mode and come back into the
evaluation mode.
To convert a km distance into miles, type run 1. To make the inverse
conversion, type run 2.
Mcalc > run 1
km-->mile : 2
2.000000000000000 km = 1.242742384474668 mile
Mcalc > run 2
mile-->km : 1.242742384474668
1.242742384474668 mile = 2.000000000000000 km
Mcalc >
A very useful feature of Mcalc is the user function keys to run a
procedure.
If you strike a SHIFT Function key, automatically it runs the procedure
from the label 0 to 9. (Label 0 is affected to Shift F10, label 1 to
Shift F1 ....).
For example, to convert now a km into mile, strike Shift F1. To convert
mile to km, strike Shift F2.
20
Mcalc : The Master Calculator.
9.6. Debugging a procedure.
---------------------------
If you suspect some fault into a procedure, it is possible to debug it.
To debug a procedure, Mcalc supplies two features selectable via the
setup command:
Procedure break enabled. =
When you run a procedure very long (or mayby error an infinite
loop), if you strike any key and this flag is set, the running
procedure is aborted. If this flag is reset, the keystroke is
ignored.
Default mode is 'Yes'.
Procedure trace mode enabled. =
When this flag is set and a procedure is running, it will run in
single step mode.
Default mode is 'No'.
Give now the setup command and modify this last flag to 'Y'. Finish
with a '/' to avoid listing all other settings. Now, Mcalc reacts
strangely with the following:
Mcalc > setup
General purpose flags:
Trigonometric mode : (R)adian, (D)egree = <D>
Programmer binary output. = <N>
Help automatically supplied. = <N>
Procedure break enabled. = <Y>
Procedure trace mode enabled. = <Y>
Display status in prompt = </>
k := 0.000000000000000 ---> 2.000000000000000
Next instruction :
end
Strike any key to continue ..., <ESC> to abort!
Strike a <ESC> and you obtain the Mcalc prompt again.
When the procedure trace mode is enabled, Mcalc displays each
instruction before executing it.
Also, each time the content of any variable 'a' to 'z' is modified,
Mcalc displays the previous and the new values. You have to strike a
key to proceed with the instruction. If you strike <ESC>, you cancel
the procedure execution and come back to the prompt. For example,
strike the Shift F1 key to convert 12 km into miles....
21
Mcalc : The Master Calculator.
Mcalc > run 1
km-->mile : 12
k := 2.000000000000000 ---> 12.000000000000000
Next instruction :
Strike any key to continue ..., <ESC> to abort!
Strike now any key, excepted <ESC>. Mcalc continues and execute the
print command...
12.000000000000000 km = 19.312128000000000 mile
Next instruction :
end
Strike any key to continue ..., <ESC> to abort!
Mcalc >
Give again the setup command and switch back the 'trace' flag to 'N'.
Keep the 'Procedure break enabled' active.
Now, write this stupid infinite loop procedure and save it as a file
under the name 'bug'.
i=1
10 print i
i=i+1
goto 10
end
Now, run it. You will see the loop is continuously restarted and you
loose the control of Mcalc.
If such occurs, it is always possible to break a running procedure by
striking any key when the procedure is running. This is only possible
if the 'Procedure break enabled' flag from setup is 'Y'. Else, your key
strokes are ignored and you have to restart your computer to keep the
control back.
If the 'Procedure break enabled' is set to 'N', the speed of running
procedure is slightly increased. Use only this setting to run safe
procedure, already debugged, and when you experience that it runs
slowly !!!
22
Mcalc : The Master Calculator.
9.7. Using an external editor.
------------------------------
The internal editor provided by Mcalc is small and fast, but very
limited in its features. This is not a major limitation of Mcalc as it
is possible to configure it to use your favourite editor. To use
another editor, called an external editor because it is not part of
Mcalc, you need to define one MSDOS environment variable.
The procedure is fully described into the registered version user
manual of Mcalc.
Remark: The registered version of Mcalc is supplied now with its own
editor: Notepad.Exe. It is strongly advised to use this
editor, as it includes special features suitable for using
when editing a keyboard macro.
10. Using the plotter and the root solver.
------------------------------------------
With Mcalc, you can plot easily any equation, or user defined function.
You can also find the root of such equation. You will find the
description and an example in the online help.
For more info: help "plot"
For more info: help "solve"
For more info: help "solve_"
If you want to plot an expression that is not directly writable in the
form of a function y=f(x), such as a parametric equation, you can write
a procedure using the 'graph' command and related commands.
For more info: help "graph"
For example, the following procedure can be used to draw a lissajou
figure:
23
Mcalc : The Master Calculator.
1 print "Lissajou figure...."
print " "
input "Enter frequency 1 : ",a
input "Enter frequency 2 : ",b
input "Number of points : ",n
d = 2 * pi / n
graph -1.2,-1.2,3.2,1.2
t=0
for i=0 to n step 1
x=2.0 * cos(a*t) + 1.0
y=sin(b*t)
if i=0 then pixel x,y,-1
line x,y
t=t+d
next
end
11. Using the statistical functions and commands.
-------------------------------------------------
Mcalc supplies the following commands and functions.
The read_ command is used to read a data structured file into the
memory variables. When the data are loaded, further statistical process
are possibles. The mean and sigma functions are available to compute
the average and the standard spread over a serie of numbers. The cor
command can be used to compute a correlation function between two
series of values. The reg command lets you compute very sophisticated
statistics. These regression results can be viewed as data tables using
listr or as graphics via plotr.
Also, Mcalc supplies two functions to study gaussian normal
distribution: normal and inormal.
For more info: help "statistics"
11.1. Reading a structured data file.
-------------------------------------
A structured data file is a text file that contains columns of values.
The demonstration file "demo05.txt" is a good example of structured
data file.
As you can see if you type or print it, this file contains a serie of
columns of values. The first line is a text that play a role of comment
for us. To load for example the data relative at a linear function, let
us give the following command:
24
Mcalc : The Master Calculator.
R_Mcalc > read_ "demo05",2,10,1,2
File loaded! Area pointer is at #26.
R_Mcalc >
For more info: help "read_"
Mcalc responds is the value of an 'Area Pointer'.
11.2. The concept of area pointer.
----------------------------------
Most statistical process, such as regression analysis or statistical
calculations are done on large series of numbers. It is thus necessary
to use a convenient notation to specify a serie of numbers quickly and
easily. This is the purpose of the Area Pointer concept used by Mcalc.
An area pointer is a block of successive contiguous memories (direct or
indirect access) whose contents give the adress of other indirect
access memories.
For more info: help "area_pointer"
The following figure illustrate the concept of Area Pointer:
Area_Pointer
│
│
│
│ Contiguous block:
└─────>── Area_X────────────────>──Contiguous block
Area_Y────────────────>──Contiguous block
Area_Z────────────────>──Contiguous block
Area_R────────────────>──Contiguous block
Area_Size
As you can see on this figure, an Area Pointer is just a succession of
5 variables. The first four contain a value that is a pointer to a
variable block. Each pointer is the indirect access adress of the first
variable of each block.
The fith value is the size of the first three blocks.
An area pointer is refered by its starting adress. This means the
indirect adress of the first pointer to the first X block. Each block
is contiguous; this means that inside a block all variables are used.
The concept of Area Pointer is powerfull enougth to works with blocks
that are not necessary contiguous with each other. This is not the case
in our previous example, but could be so.
25
Mcalc : The Master Calculator.
Summary: Each time you load a data serie from a data structured file
using the read_ command, Mcalc returns you the adress of an
Area Pointer. This unique adress will be used to specify your
data during each regression calculus.
11.3. Computing single statistics.
----------------------------------
When your data are loaded into memory, you can use the mean and sigma
functions to perform statistical calculations. In our previous example,
we have loaded two series of numbers representing the x and y values
for 10 points. Let us now compute the mean and average of x series....
For more info: help "mean"
See also related topics: sigma, min and max.
R_Mcalc > mean(40,10)
Answer = 16.75
R_Mcalc > sigma(40,10)
Answer = 4.54147553114624
11.4. Performing linear and non-linear regression analysis.
-----------------------------------------------------------
A linear regression analysis can be computed directly using the reg
command. The command uses the following syntax:
reg area pointer , 0 , order
In fact, Mcalc performs a polynomial regresssion. Order is the degree
of the polynome. By specifing a order=1, you obtain a linear
regression. Compute the linear regression from the already loaded data
of the previous example:
R_Mcalc > reg 26,0,1
Regression in progress! Please wait ....
Regression results:
Coef[00]= 3
Coef[01]= 2
Regression sigma = 0
Correlation = 1
R_Mcalc >
For more info: help "reg"
For more info: help "plotr"
For more info: help "listr"
26
Mcalc : The Master Calculator.
11.5. Manual regression using the solver.
-----------------------------------------
Despite the fact that the Mcalc user defined model offers already a lot
of possibilities, there are situations where the equation cannot be
defined with any of the previous model. In such situation, it is still
possible to perform a regression using a least square criterium model,
via a combination of a Procedure, the solver and an iteration
algorithm.
You will find a full chapter dedicated to this subject, with worked
examples, in the manual supplied with the registered version of Mcalc.
12. Numerical analysis.
-----------------------
Mcalc supplies also special commands used for numerical analysis.
For more info: help "integral"
For more info: help "interpol"
This shareware package is supplied with the procedure "demo04.mcp" that
can be used to draw an interpolated curve going through a serie of data
points loaded via 'read_' or computed and stored in memory by any other
method. Refer also to the demonstration to see directly that procedure
at work.
13. Physical units conversion.
------------------------------
Mcalc is supplied with a database of up to around 100 units. Via the
'convert', 'rconv' and 'iconv' commands, you can convert values between
units.
For more info: help "convert"
The registered version of Mcalc is supplied with an utility that can be
used to customize the database following your needs. A database have
space for up to 200 units!
27
Mcalc : The Master Calculator.
14. Using keyboard macros.
--------------------------
Mcalc supports keyboard macros. A macro is just a sequence of
keystrokes that can be played automatically after you have stored them
into a file. The compleet demonstration used in this package has been
implementated as an unique macro.
For more info: help "macro"
The macro compiler and the description of how to write and run macros
are described in details in the registered version of Mcalc.
15. Advanced and particular topics.
-----------------------------------
15.1. Session log file support.
-------------------------------
If you use a small desk calculator, you are sometimes happy having a
paper roll printout of al the operations you perform. By that way, if
you discover a mistake after a long series of operations, you can
always look at the paper to find your error or to remember how you did
some specific calculations.
A similar facility is available with Mcalc and is called the log file.
A log file is a text file where all the dialog from the main screen can
be redirected. To use the log file system, you just use two commands:
write and close.
The write command is used to specify the loggin file you want the
listing of your current session to go. You may get the loggin on any
ASCII text file, or on the line printer.
For example, to make a log file 'mylog.txt' of the current session,
give the following command:
D_Mcalc > write "mylog.txt"
D_Mcalc >
Now, all the dialog you type and Mcalc answers go to that file. This is
true, as well in evaluation mode, as all 'print' instructions in
procedure mode. The log file is appended until:
- you use another 'write' command.
- you close the logger with the 'close' command.
- you quit Mcalc with the 'quit' command.
28
Mcalc : The Master Calculator.
If the specified log file already exists, it is appended; it is never
overwritten. Please, refer to the on-line help for the compleat syntax
of the 'write' command.
In the log file, your input commands (in evaluation mode) are always
preceded by a ';' character.
Mcalc answers looks exactly as they come on the screen. The debugging
information in trace mode, or the iterations of the solver are not
copied to the log file.
15.2. The initialization 'mcalc.mcp' procedure.
-----------------------------------------------
When you start Mcalc, it search in the working directory for a
procedure named 'Mcalc'. If it find it, it will run it automatically( a
little bit as the 'autoexec.bat' file of your PC). By that way, you
have the possibility to initialize some variables or to open always a
log file, or thinks like that. You must take care of two things, when
you create this procedure:
- it must always finish with the 'end' instruction.
- it may not include instructions like 'setup' that initiate a
dialog (or you have to answer the dialog before the procedure
will continue). This is true for any kind of procedure.
Tips: The 'mcalc' procedure can be very useful if you plan to
work always with the same ten user functions Shift_F1 to
Shift_F10. In such case, write a procedure with multiple
entries as described in chapter 4. Preceded the first
label by a line with 'end' or the initialization
procedure finished by 'end'. So, each time you start
Mcalc, the initialization is done and your keystroke
procedures are available. Another way to work is to
create one simple initialisation procedure that contains
and finish with a 'load' instruction, such that your
favourite procedure is directly available when you start
Mcalc.
29
Mcalc : The Master Calculator.
15.3. Using the command line mode.
----------------------------------
The command line mode is a special case of the evaluation mode.
If you have only one calculation to do, it is possible to specify the
expression directly into the command line, at the same time you type
'mcalc' to start Mcalc. For example, from the DOS prompt, type the
following to make this calculation:
C:\TOOLS>mcalc sqrt(1-cos(30)^2)
Answer = 0.5
C:\TOOLS>
If the expression you type at the command prompt could interfere with
MSDOS, enclose it within quotes....
C:\C\SOURCE>mcalc 12/5
Answer = 2.4
C:\C\SOURCE>mcalc 12 / 5
Answer = 12
C:\C\SOURCE>mcalc "12 / 5"
Answer = 2.4
C:\C\SOURCE>
In the first case, Mcalc recognizes a correct expression, because
'12/5' was in one word. In the second case, Mcalc make a mistake
because MSDOS interprets ' 12 / 5 ' as three different words, and Mcalc
expects only one expression in the command line. The third example is
correct, because MSDOS recognizes this time the whole expression
between quotes as one unique word.
15.4. Using graphical fonts files.
----------------------------------
When in graphical mode, Mcalc can use character fonts to improve the
graphic quality. A graphic font is a file having a .FON extension, like
the one delivered with Windows 3.1. This package is delivered with the
file HELVB.FON that contains Helvetica fonts you can use if you have an
EGA or VGA adapter. To use this font file with a EGA or VGA adapter,
and assuming you have copied all Mcalc files into the subdirectory
c:\mcalc, you must give the two commands before starting Mcalc:
30
Mcalc : The Master Calculator.
set fontdir=c:\mcalc
set fontface=t'helv'w10h8b
You could for example add these two commands into your autoexec.bat
file.
Before using fonts, you must also enable their usage via the 'setup'
command.
For more info: help "setup"
15.5. Customizing user function keys.
-------------------------------------
The Mcalc package is supplied with the mcalc.key file. This file
contains the definition assigned to the function keys F1 to F10, Shift,
Ctrl & Alt, inside Mcalc. To view the current assignment of these keys,
give the listk command.
The registered version of Mcalc is distributed with the two files:
mckey.lst and mckey.exe.
With these two files, you have the possibility to modify the user key
definitions as you want.
For more info: help "mckey"
31
Mcalc : The Master Calculator.
16. The Mcalc files.
--------------------
Version 1.99 of Mcalc uses and recognizes the following files:
mcalc.exe is the Mcalc program itself.
mcalc.hlp & mcalc.hl2 are the online help files. The first contains
all the help material, while the second
supplies the fast access index system.
mcalc.ini is the file that store your current setup. It
is created the first time you run Mcalc.
mcalc.lic is the license information file for registered
users.
helvb.fon is the Helveticca fonts characters to use in
graphic mode.
.mcp all Master Calculator Procedures are text
files having that extension.
.mem all variables dump files produced with
'savevar'.
mc_unit.dat the database of physical units.
mcalc.key the user keys definition file (compiled).
mckey.lst the user keys definition file (source).
mckey.exe utility to make mcalc.key.
makeunit.exe utility to edit mc_unit.dat.
notepad.* the supplied editor.
assist.exe the assistant add-in.
mac.exe & mcmac.exe the macro compiler and its driver.
Remark: Not all these files are supplied with the shareware version!
32